<% admin_breadcrumb(link_to Spree.t(:stock), spree.admin_stock_items_path) %>
<% admin_breadcrumb(Spree::StockTransfer.model_name.human, @stock_transfer.number) %>


<% content_for :page_actions do %>
  <li>
    <%= button_link_to Spree.t(:back_to_stock_transfers_list), admin_stock_transfers_path %>
  </li>
<% end %>

<fieldset class="no-border-bottom">
  <%= render 'spree/admin/stock_transfers/location', stock_transfer: @stock_transfer %>

  <div>
    <label><%= Spree::StockTransfer.human_attribute_name(:description) %></label>
    <p><%= @stock_transfer.description %></p>
  </div>

  <div class="row">
    <div class='field-block col-xs-3'>
      <label><%= Spree::StockTransfer.human_attribute_name(:created_by_id) %></label>
      <p><%= @stock_transfer.created_by.email %></p>
    </div>

    <div class='field-block col-xs-2'>
      <label><%= Spree::StockTransfer.human_attribute_name(:created_at) %></label>
      <p><%= @stock_transfer.created_at.try(:to_date) %></p>
    </div>

    <div class='field-block col-xs-2'>
      <label><%= Spree::StockTransfer.human_attribute_name(:finalized_at) %></label>
      <p><%= @stock_transfer.finalized_at.try(:to_date) %></p>
    </div>

    <div class='field-block col-xs-3'>
      <label><%= Spree::StockTransfer.human_attribute_name(:finalized_by_id) %></label>
      <p><%= @stock_transfer.finalized_by.try(:email) %></p>
    </div>

    <div class='field-block col-xs-2'>
      <label><%= Spree::StockTransfer.human_attribute_name(:shipped_at) %></label>
      <p><%= @stock_transfer.shipped_at.try(:to_date) %></p>
    </div>
  </div> 
</fieldset>

<fieldset>
  <legend><%= plural_resource_name(Spree::TransferItem) %></legend>
  <%= render partial: 'transfer_item_table', locals: { transfer_items: @stock_transfer.transfer_items, show_expected: true, show_received: true, show_actions: false } %>
</fieldset>
